from django.db import models

# Create your models here.
from products.models import goods_info
from LoginSign.models import User
from django.utils import timezone

#商品广告表
class mall_carousel(models.Model):
    carousel_url=models.CharField(max_length=500)#广告的图片链接
    redirect_url=models.CharField(max_length=500)#广告的链接
    carousel_rand=models.IntegerField()#广告排序
    is_deleted=models.BooleanField(default=False)
    create_time = models.DateTimeField(default=timezone.now)  # 创建时间
    update_time = models.DateTimeField(default=timezone.now)  # 更新时间
    create_user = models.IntegerField()  # 创建这个分类信息的用户
    update_user = models.IntegerField()  # 更新这个分类信息的用户

#首页设置
class HomeConfig(models.Model):
    name=models.CharField(max_length=50)#首页的名字
    type=models.CharField(max_length=50)#首页的类型
    goods_id=models.ForeignKey(goods_info,models.SET_NULL,null=True,related_name='homeconfig')
    redirect_url=models.CharField(max_length=200)
    config_rank=models.IntegerField()#首页排名
    is_deleted=models.BooleanField(default=False)
    create_time = models.DateTimeField(default=timezone.now)  # 创建时间
    update_time = models.DateTimeField(default=timezone.now)  # 更新时间
    create_user = models.IntegerField()  # 创建这个分类信息的用户
    update_user = models.IntegerField()  # 更新这个分类信息的用户

    class Meta:
        db_table='homeconfig'


#收藏
class collection(models.Model):
    goods_id=models.ForeignKey(goods_info,models.SET_NULL,null=True,related_name='collections')
    user_id=models.ForeignKey(User,models.CASCADE,related_name='collections')
    create_time=models.DateTimeField(default=timezone.now)


